<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>04-计算属性和命令式回调</title>
</head>
<body>
  <!-- 计算属性 -->
  <div id="app1">
    {{ fullName }}
  </div>
  <!-- //计算属性 -->

  <!-- 命令式回调 -->
  <div id="app2">
      {{ fullName}}
  </div>
  <!-- //命令式回调 -->
</body>
<script src="./vue1111.js"></script>
<script>
  var vm = new Vue({
    el:'#app1',
    data:{
      firstName:'Foo',
      lastName:'Bar',
    },
    computed: {
      fullName(){
        return this.firstName + '' + this.lastName
      }
    },
  });

  var vm1 = new Vue({
    el:'#app2',
    data:{
      firstName:'Foo',
      lastName:'Bar',
      fullName:'FooBar',
    },
    watch:{
      firstName(val){
        this.fullName = val + '' + this.lastName
      },
      lastName(val){
        this.fullName = this.firstName + '' + val
      }
    }
  })
</script>
</html>